Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #2638] "unwanted" toasts - HatsTreeId not getting reset when Network Changes #2639

Merged
merged 11 commits into from
Dec 19, 2024

Conversation

Da-Colon
Copy link
Contributor

Closes #2638

Did a little refactor as well as with some additional testing. I noticed there was additional calls when switching DAOs because of the extra useEffect.

So refactored useHatsTree a little:

  • Extracted the async function into callback, accepting some params
  • removed sablier payments useEffect
  • added payments retrieval to sanitize method in setHatTree workflow

other change:

  • fixed conditional I placed in useKeyValuePairs causing some issues.

Copy link

netlify bot commented Dec 18, 2024

Deploy Preview for decent-interface-dev ready!

Name Link
🔨 Latest commit 2ac122d
🔍 Latest deploy log https://app.netlify.com/sites/decent-interface-dev/deploys/6762570afad3710008c42677
😎 Deploy Preview https://deploy-preview-2639.app.dev.decentdao.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 18, 2024

Deploy Preview for decent-interface-dev ready!

Name Link
🔨 Latest commit f4a8fa8
🔍 Latest deploy log https://app.netlify.com/sites/decent-interface-dev/deploys/676424d2f6c0c700080df1da
😎 Deploy Preview https://deploy-preview-2639.app.dev.decentdao.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@DarksightKellar
Copy link
Contributor

Still got it =(
Screenshot 2024-12-18 at 12 57 35

Context:

  • Add 0x374D5a17D2433415C48C735A493F0523DaB99041, 0xB98d45F9021D71E6Fc30b43FD37FB3b1Bf12c064 to faves.
  • Unconnected wallet the entire time
  • Switch between myosin and decent daos via the dropdown menu. It appears switching via the homepage doesn't show the toast

@Da-Colon
Copy link
Contributor Author

Really not sure what to do here.

Problem:
When DAO is set and urlAddress changes the chain events are:

  • url address and url network prefix changes
  • useAutomaticChainSwitcher picks up different network and triggers network change adds to stack
  • useFractalNode picks up on on different address and triggers global store reset adds to stack
  • useHatsTree picks up on network changes and fires getHatTree (global and role state not reset yet) <----Here is where the toasts happen
  • useKeyValuePairs picks up on address being updated after store reset
  • useFractalNode picks up on network settling and loads new DAO info
  • new DAO loads, new HatTreeId is retrieved, new HatTree is retrieved

@DarksightKellar
Copy link
Contributor

I can try looking into this tomorrow. Can I assume that myosin DAO has no hat tree and might be part of the reason this happens? Cz this is happening in only one direction -- when switching to myosin

@Da-Colon
Copy link
Contributor Author

Da-Colon commented Dec 18, 2024

@DarksightKellar its also happening for any DAO switching. it does fix itself for DAOs that already have a Hattree but it still will load the previous DAOs hattree as the Hattree ID doesn't get removed in time.

I have plenty of ways that I COULD fix it. I just was hoping to discuss this in realtime to figure out a proper fix. Its the same problem that the other 'load' keys refs were created to fix.

This has been an issue since smartAccounts were added. if there was a problem it kinda would keep going with the smartAddress being undefined

I just now show it loud clear from the update to sanitize to throw some errors when business logic isn't met.

Copy link
Contributor Author

@Da-Colon Da-Colon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating the useEffect hook in useHatsTree to be:

  const node = useDaoInfoStore();
  const safeAddress = node.safe?.address;
  const loadKey = useRef<string | null | undefined>(undefined);
  useEffect(() => {
    const key = safeAddress && hatsTreeId ? `${safeAddress}:${hatsTreeId}` : null;
    if (
      !!hatsTreeId &&
      !!contextChainId &&
      !!publicClient &&
      key !== null &&
      key !== loadKey.current
    ) {
      getHatsTree({
        hatsTreeId,
        contextChainId,
        publicClient,
      });
    }
    loadKey.current = key;
  }, [contextChainId, getHatsTree, hatsTreeId, publicClient, safeAddress]);
};

fixes this bug.

@Da-Colon Da-Colon force-pushed the issue/2638-unwanted-toasts branch from 8e88522 to 8ceb565 Compare December 18, 2024 21:23
@Da-Colon Da-Colon changed the title [Issue #2638] unwanted toasts [Issue #2638] "unwanted" toasts - HatsTreeId not getting reset when Network Changes Dec 18, 2024
@DarksightKellar
Copy link
Contributor

@Da-Colon the toast was still occurring for me (on netlify and local), so I pushed the loadkey a bit further. Seems to be cool now

Copy link
Member

@adamgall adamgall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarksightKellar remove the console.log then seems good to me. thanks @Da-Colon and @DarksightKellar

@adamgall adamgall merged commit f2a0710 into develop Dec 19, 2024
7 checks passed
@adamgall adamgall deleted the issue/2638-unwanted-toasts branch December 19, 2024 15:05
@adamgall adamgall mentioned this pull request Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unwanted toasts showing when navigating to a DAO of different network
3 participants